package com.aceitunaproject.server.installation;

import java.util.List;
import java.util.Map;


import com.aceitunaproject.server.equipment.Equipment;
import com.aceitunaproject.server.materialgoods.GoodProduction;
import com.aceitunaproject.server.materialgoods.MaterialGood;
import com.aceitunaproject.server.science.ScientificAdvance;

/**
 * 
 * @author Federico Bergstein
 * 
 * 
 *         A type of installation.
 */
public class InstallationType {

	private String defaultName;
	private List<ScientificAdvance> requiredScientificAdvances;
	private List<Equipment> buildingRequiredEquipment;
	private Map<MaterialGood, Long> buildingRequiredGoods;
	private List<GoodProduction> producedGoods;
	private int maxPersonsBuilding;
	private int manTicks;

	/**
	 * sets the default, non-localized, name of the installation type, which
	 * also functions as it's id.
	 * 
	 * @param defaultName
	 *            the default, non-localized, name of the installation type
	 */
	public void setDefaultName(String defaultName) {
		this.defaultName = defaultName;
	}

	/**
	 * @param buildingRequiredEquipment
	 * @param buildingRequiredGoods
	 * @param defaultName
	 * @param producedGoods
	 * @param requiredScientificAdvances
	 */
	public InstallationType(List<Equipment> buildingRequiredEquipment,
			Map<MaterialGood, Long> buildingRequiredGoods, String defaultName,
			List<GoodProduction> producedGoods,
			List<ScientificAdvance> requiredScientificAdvances,
			int maxPersonBuilding, int manTicks) {
		this.buildingRequiredEquipment = buildingRequiredEquipment;
		this.buildingRequiredGoods = buildingRequiredGoods;
		this.defaultName = defaultName;
		this.producedGoods = producedGoods;
		this.requiredScientificAdvances = requiredScientificAdvances;
		this.maxPersonsBuilding = maxPersonBuilding;
		this.manTicks = manTicks;
	}

	

	/**
	 * @return the default, non-localized, name of the installation type
	 */
	public String getDefaultName() {
		return defaultName;
	}

	/**
	 * @param the
	 *            Scientific Advances required to build/operate installations of
	 *            this type.
	 */
	public void setRequiredScientificAdvances(
			List<ScientificAdvance> requiredScientificAdvances) {
		this.requiredScientificAdvances = requiredScientificAdvances;
	}

	/**
	 * @return the Scientific Advances required to build/operate installations
	 *         of this type.
	 */
	public List<ScientificAdvance> getRequiredScientificAdvances() {
		return requiredScientificAdvances;
	}

	/**
	 * @param the
	 *            Equipment an unit needs to build this type of installation
	 */
	public void setBuildingRequiredEquipment(
			List<Equipment> buildingRequiredEquipment) {
		this.buildingRequiredEquipment = buildingRequiredEquipment;
	}

	/**
	 * @return the Equipment an unit needs to build this type of installation
	 */
	public List<Equipment> getBuildingRequiredEquipment() {
		return buildingRequiredEquipment;
	}

	/**
	 * @param the
	 *            materials needed to build an installation of this type
	 */
	public void setBuildingRequiredGoods(
			Map<MaterialGood, Long> buildingRequiredGoods) {
		this.buildingRequiredGoods = buildingRequiredGoods;
	}

	/**
	 * @return the materials needed to build an installation of this type
	 */
	public Map<MaterialGood,Long> getBuildingRequiredGoods() {
		return buildingRequiredGoods;
	}

	/**
	 * @param the
	 *            list of GoodProduction objects that determine the installation
	 *            production
	 */
	public void setProducedGoods(List<GoodProduction> producedGoods) {
		this.producedGoods = producedGoods;
	}

	/**
	 * @return the list of GoodProduction objects that determine the
	 *         installation production
	 */
	public List<GoodProduction> getProducedGoods() {
		return producedGoods;
	}

	
	
	/**
	 * @param manTicks
	 *            the ticks required to build this installation with an 1 person unit
	 */
	public void setManTicks(int manTicks) {
		this.manTicks = manTicks;
	}

	/**
	 * @return the manTicks
	 */
	public int getManTicks() {
		return manTicks;
	}

	/**
	 * @param the maximum number of persons that can work to build this installation
	 *            
	 */
	public void setMaxPersonsBuilding(int maxPersonsBuilding) {
		this.maxPersonsBuilding = maxPersonsBuilding;
	}

	/**
	 * @return the maximum number of persons that can work to build this installation
	 */
	public int getMaxPersonsBuilding() {
		return maxPersonsBuilding;
	}
	

	@Override
	public boolean equals(Object anObject)
	{
		if (!super.equals(anObject)) {
			if (anObject instanceof InstallationType) {

				InstallationType comparisonObject = (InstallationType) anObject;

				return (this.getDefaultName() == comparisonObject.getDefaultName());

			} else {
				return false;
			}
		} else {
			return true;
		}
	}

}
